<?php
$link=mysql_connect("localhost","root","1234");
mysql_select_db("it341_db2",$link);

if(isset($_POST['customer'])){
	$name= $_POST['name'];
	$address = $_POST['address'];
	$type = $_POST['type'];
	if($name!=""){
		$sql="select*from customer";//select  customer ทั้งหมด
		$result = mysql_query($sql,$link);//คำสั่งเรียกใช้คำสั่ง $sql
		$cust_id = mysql_num_rows($result)+1;//นับจำนวนแถวแล้วเอามาบวก 1 เรื่อยๆ
		$insert_customer = "insert into customer values($cust_id,'$name','$type','$address')";
		
		mysql_query($insert_customer,$link);
	}
}
mysql_close($link);
?>